//02.maxfopen.c
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

int main() {
    int count = 0;
    FILE *fp = NULL;
    while(1) {
        fp = fopen("tmp","r");
        if (fp == NULL) { perror("fopen()"); break; }
        count++;
    }
    // (带上标准输入、输出、错误输出，一共1024个) 用ulimit -a看open files
    printf("%d\n",count); //1021
    return 0;
}